#!/usr/bin/env python
import sys

class Primes():
    def __init__(self):
        self.primes = [2, 3]
        self.upper = 3
    def gen_primes(self, n):
        if self.upper < n:
            self.upper = n
        for i in range(self.upper, n+1):
            flag = 0
            for j in self.primes:
                if i%j == 0:
                    flag = 1
                    break
            if flag != 1:
                self.primes.append(i) 
        return self.primes

sys.stdin = open('data', 'r')
n = int(sys.stdin.readline())
p = Primes()

for line in sys.stdin:
    a, b = line.split(' ')
    l = p.gen_primes(int(b))
    for i in l:
        if i>= int(a) and i<=int(b):
            print i
    n -= 1 
    if n>= 1:
        print 

